package com.example;

public class NumberMethods {

    public static void main(String[] args) {
        NumberMethods numberMethods = new NumberMethods();
        numberMethods.testNumberMethods();
    }

    void testNumberMethods() {
        Integer num = 12;
        System.out.println("num.toString() = " + num.toString());
        System.out.println("num.byteValue() = " + num.byteValue());
        System.out.println("num.doubleValue() = " + num.doubleValue());
        System.out.println("num.shortValue() = " + num.shortValue());
        // 比较两个数的大小 如果指定的数与参数相等返回 0。如果指定的数小于参数返回 - 1。如果指定的数大于参数返回 1。  注意：只能比较相同数据类型
        System.out.println("num.compareTo() = " + num.compareTo(2)); //1 
        System.out.println("num.compareTo() = " + num.compareTo(12)); //0
        System.out.println("num.compareTo() = " + num.compareTo(13)); //-1

        Integer x = 5;
        Integer y = 10;
        Integer z = 5;
        Short a = 5;

        System.out.println(x.equals(y)); //false
        System.out.println(x.equals(z)); //true
        System.out.println(x.equals(a)); //false

        Integer i = Integer.valueOf("123"); //123
        Double j = Double.valueOf("142"); //142.0
        Float k = Float.valueOf("121"); //121.0
        System.out.println(i);
        System.out.println(j);
        System.out.println(k);

        Integer m = Integer.parseInt("123"); //123  
        Double n = Double.parseDouble("142"); //142.0
        Float o = Float.parseFloat("121"); //121.0
        System.out.println(m);
        System.out.println(n);
        System.out.println(o);
    }
}
